package net.underrealm.src;

import java.io.File;
import java.io.IOException;

import org.ur_lwg.utils.Utils;

import net.underrealm.client.UnderRealm;

public class FileManager {
	
	public FileManager(UnderRealm main) 
	{
	
	}
	
	
	
	public void openFile(String fileDir) {
		File file = new File(fileDir);
		Utils.println("Loaded File: " + file.getName());
	}
	
	public void writeFile(String fileDir) {
		File file = new File(fileDir);
		if(!file.canWrite()) {
			return;
		}
		
	}
	
	public void createCacheDir() {

			this.createDir(this.mainCacheDirWin);
			this.createDir(this.mainCacheDirWin + "\\bins");
			this.createDir(this.mainCacheDirWin + "\\config");
			this.createDir(this.mainCacheDirWin + "\\cache");
			this.createFile(this.mainCacheDirWin + "/cache/" + this.cacheTxt);
			this.createFile(this.mainCacheDirWin + "/config/" + this.gameConfig);
		
	}
	
	public String getUnderReamDir() {
			return this.mainCacheDirWin;
	}
	public void createDir(String fileDir) {
		File file = new File(fileDir);
		if(file.exists()) {
			return;
		} else {
			file.mkdir();
			System.out.println("Created Dir " + file.getName());
		}
	}
	
	public void cdDir(String s) {
		this.dirIn = s;
		Utils.println("Changed Dir to " + this.dirIn);
	}
	
	public void createFile(String fileDir) {
		File file = new File(fileDir);
		if(!file.exists()) {
			try {
				file.createNewFile();
				System.out.println("Created new file " + file.getName());
			} catch (IOException e) {
				System.out.println("Error creating new file " + file.getName());
				e.printStackTrace();
			}
		}
	}
	
	public String mainCacheDirMac = "/Users/christianhorton/Library/Application Support/underrealm";
	public String mainCacheDirWin = "C://Users//SystexPro//AppData//Roaming//underrealm";
	public String dirIn;
	public String cacheTxt = "cache.txt";
	public String gameConfig = "gamesettings.config";
}
